//字段管理
import React, { useState, useEffect } from "react";
import CommonLoading from "@/components/CommonLoading";
import { queryFieldManageList } from "../service";
import InfoContent from "./component/InfoContent";

const CodeManage = () => {
	const [data, setData] = useState({}); //展示数据
	const [loading, setLoading] = useState(false);

	useEffect(() => {
		getFieldManageList();
	}, []);

	const getFieldManageList = async () => {
		setLoading(true);
		const { data = [], success } = await queryFieldManageList();
		if (success) {
			setData(data);
		}
		setLoading(false);
	};

	const newGoodsInfoList = data?.goodsInfoList?.filter(item => !['商品编码行', '商品数量行', '款式编码行'].includes(item.name.slice(0, 5)));

	return (
		<div style={{ height: "calc(100vh - 150px)" }}>
			<div style={{ height: "100%", overflow: "auto" }}>
				<InfoContent title="商品信息" data={newGoodsInfoList} />
				<InfoContent title="订单信息" data={data?.orderInfoList} />
				<InfoContent title="入库单信息" data={data?.libraryInfoList} />
				<InfoContent title="采购单信息" data={data?.purchaseInfoList} />
				<InfoContent title="其他信息" data={data?.otherInfoList} />
				<CommonLoading loading={loading} />
			</div>
		</div>
	);
};

export default CodeManage;
